<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('选品库')" />
	<th:block th:include="include :: businessCSS" />
	<style>

		.preservationBtn{padding: 10px;text-align: center;}
		.preservationBtn input{font-size: 16px;background-color: rgb(80, 138, 238);color: #fff;border: none;padding: 5px 30px;border-radius: 10px;cursor: pointer;}

	</style>

</head>

<body class="no-skin">
<div class="main-container" id="main-container">
	<div class="main-content">
	<form class="layui-form head-form">
	    <div class="north" style="background-color: #fff;">
			<div class="forminput"></div>
			<div class="layui-form-item preservationBtn">
				<input type="button" lay-submit lay-filter="btn-add" id="btn-add" value="保存">
			</div>
    	</div>
    </form>
	</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: businessJS" />
<!-- <th:block th:include="include :: inlineJS" /> -->

<script th:inline="javascript">
	/*<![CDATA[*/
	var prefix = ctx + "business/productactive",
    	prefix2 = ctx + "base/company";
	var	k_fields=[]
	var fields = [[${fields}]];
	var fieldsList = [[${fieldsList}]];
	var fieldsHiddenList = [[${fieldsHiddenList}]];
	var gridColumns= [[${gridColumns}]];
	var all_fields= fieldsList;

	var $,layer,form,table;
    layui.use(['laydate','form','layer','jquery','util','element','upload'], function () {
        $ = layui.$,layer = layui.layer,form = layui.form,laydate = layui.laydate,util = layui.util,element=layui.element,upload = layui.upload;
		headcom()
		form.on('submit(btn-add)', function(data){
    	//    data.field.disabled = data.field.disabled === "on" ? "0":"1";
		    var is_return = false//是否中断保存
            fieldsList.map((v,i)=>{
                if(v.fieldFrontRequired){
                    if(!$('#'+v.fields).val()){
                         layer.msg(v.fieldName+'不能为空')
                         is_return=true
                    }
                }
            })
            if(is_return) return;
    	   var postStr = [];
		   postStr.push(data.field);
		   $.post("/business/productactive/addpost",{productActiveItems:JSON.stringify([data.field])},function(res){
				 layer.msg(res.msg);
	       });
           return false;
       });
	   

	   assemblyhead()


		// beforeInit();//表单初始化之前的动作集合
		// layui.element.render();

    });

	/*]]>*/
</script>

</body>
</html>